You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deploy.json already has "init" for systems.
But systems are contracts. Scripts are best run through libraries.
Example:
An expensive addItem function, which adds a game item prototype with all its properties. Say it costs 1mil gas per item. I have an initializer which adds 100 of those. 100mil gas exceeds the limit.
If the 100 adds are in a system contract, it will revert. And making a bunch of wrapper init systems is a really bad idea.
If the 100 adds are in a library, forge script can at least split it into several transactions. But also the real contract calls (component sets) use only a small portion of all that gas.
(this is a simplified edge case, my real use case is unfinished and more convoluted, but similar enough, e.g. InitEquipmentAffixSystem uses way more than the transaction gas limit)
I tested that it minimally works via a slightly modified emojimon, if you wanna just clone it.
Some concerns:
libs may not be the best name, open to suggestions
The whole idea of modifying LibDeploy may be a bit too hardcodey. Maybe having a user-controllable Deploy.sol would be best. But that's way beyond the scope of this simple PR. (feat(cli): allow arbitrary project structure for LibDeploy and system types #309 kinda goes in that direction a bit, making scripts more local)
I wonder if it's worth adding a scripts directory (and follow the foundry *.s.sol naming scheme) to keep the initialization scripts/logic separate from the long-running logic (libs).
I wonder if it's worth adding a scripts directory (and follow the foundry *.s.sol naming scheme) to keep the initialization scripts/logic separate from the long-running logic (libs).
scripts is kinda like src, test, out, it should exist in the root (according to the defaults of foundry book, and my preference).
Something like Deploy.sol is a script (#311 is related), and should probably be Deploy.s.sol.
But I would prefer libraries that are used by scripts to still be inside src. They can be however kept in a separate dir from the other libs. This is mostly because #309 needs libs in src, but also allows them to be in arbitrary subfolders (for example src/init for init libs).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
deploy.json already has "init" for systems.
But systems are contracts. Scripts are best run through libraries.
Example:
An expensive
addItemfunction, which adds a game item prototype with all its properties. Say it costs 1mil gas per item. I have an initializer which adds 100 of those. 100mil gas exceeds the limit.forge scriptcan at least split it into several transactions. But also the real contract calls (component sets) use only a small portion of all that gas.(this is a simplified edge case, my real use case is unfinished and more convoluted, but similar enough, e.g. InitEquipmentAffixSystem uses way more than the transaction gas limit)
I tested that it minimally works via a slightly modified emojimon, if you wanna just clone it.
Some concerns:
libsmay not be the best name, open to suggestionsLibDeploymay be a bit too hardcodey. Maybe having a user-controllableDeploy.solwould be best. But that's way beyond the scope of this simple PR. (feat(cli): allow arbitrary project structure for LibDeploy and system types #309 kinda goes in that direction a bit, making scripts more local)